import { createStore,applyMiddleware } from 'redux'
import { defReducer } from './reducers'

// 导入 saga 最终需要去 run 一下,执行一下 saga
import { defSaga } from './sagas'

// 导入 createSagaMiddleware
import createSagaMiddleware from 'redux-saga'

// 调用这个函数,来构建 SagaMiddleware
const SagaMiddleware = createSagaMiddleware()

// 构建 store'
// createStore(reducer,initState,中间件)
// 通过 applyMiddleware 来关联
export default createStore(defReducer,{},applyMiddleware(SagaMiddleware))

// 利用 middleware 来 run 一下
SagaMiddleware.run(defSaga);